package com.boardgame.gwt.service.operate.action.forest;

import java.util.regex.Matcher;

import com.boardgame.common.entity.ResponseInfo;
import com.boardgame.gwt.data.GwtGameBoard;
import com.boardgame.gwt.data.GwtPlayerInfo;
import com.boardgame.gwt.service.operate.SyntaxBaseAction;
import com.boardgame.gwt.service.operate.SyntaxRequest;
/**
 * 跟树林相关的行动
 * @author Eric_Zhu
 *
 */
public abstract class ForestBaseAction extends SyntaxBaseAction {

	/**
	 * 获取玩家树林建筑数量
	 * @return
	 */
	public int getForestBuildingCount() {

        //这里应该有一段获取玩家树林建筑数量的代码。。。。。。。。。。。
		return 0;
	}
	
	public GwtPlayerInfo getCurrentPlayer() {
		return this.gwtGameBoard.getCurrentPlayer();
	}

    @Override
    public ResponseInfo action(GwtGameBoard gwtGameBoard, SyntaxRequest syntaxRequest, Matcher matcher) {
        super.action(gwtGameBoard, syntaxRequest, matcher);
        //当前玩家
        GwtPlayerInfo gwtPlayer = super.gwtGameBoard.getCurrentPlayer();
        
        //根据树林建筑次数执行奖励
        int forestCount = this.getForestBuildingCount();
        for(int i = 0; i < forestCount; i++) {
        	this.forestAction(gwtGameBoard, syntaxRequest, matcher);
        }

        return ResponseInfo.Success(null);
    }
    

    /**
     * 奖励
     * @return
     */
    protected abstract ResponseInfo forestAction(GwtGameBoard gwtGameBoard, SyntaxRequest syntaxRequest, Matcher matcher);
}
